﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="StockType.aspx.cs" Inherits="DevExpressWebApplication1.Module.MM.StockType" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
     <script type="text/javascript">
         function openAdd() {
             hdfStockType.Set("StockTypeId", -1);
             ClearData();
             popupAddEdit.Show();
         }
         function EditStockType() {
             // var key = gvStockType.GetRowKey(gvStockType.GetFocusedRowIndex());
             var index = gvStockType.GetFocusedRowIndex();
             cbAddEdit.PerformCallback('Edit;' + index);
             popupAddEdit.Show();
         }
         function ClearData() {
             txtStockType.SetValue('');
             txtDescription.SetValue('');
         }

    </script>
    <div class="span10">
        <dx:ASPxButton runat="server" ID="btnAdd" Text="Add" Theme="DevEx" UseSubmitBehavior="False" AutoPostBack="False">
            <ClientSideEvents Click="function(s,e){openAdd()}" />
        </dx:ASPxButton>
    </div>
    <div class="span10">
        <dx:ASPxGridView ID="gvStockType" ClientInstanceName="gvStockType" OnCustomCallback="gvStockType_CustomCallback" ClientIDMode="Static"
            Width="100%" runat="server" AutoGenerateColumns="False" DataSourceID="dsStockType" KeyFieldName="stock_type_id" Theme="DevEx">
            <ClientSideEvents RowDblClick="function(s,e){ EditStockType() }" />
            <Columns>
                <dx:GridViewDataTextColumn FieldName="stock_type_id" ReadOnly="True" VisibleIndex="0">
                    <EditFormSettings Visible="False" />
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="stock_type_name" VisibleIndex="1">
                </dx:GridViewDataTextColumn>
                <dx:GridViewDataTextColumn FieldName="description" VisibleIndex="2">
                </dx:GridViewDataTextColumn>
            </Columns>
            <SettingsBehavior AllowFocusedRow="True" />
        </dx:ASPxGridView>
    </div>
    <asp:SqlDataSource ID="dsStockType" runat="server" ConnectionString="<%$ ConnectionStrings:PPL_ERPConnectionString %>" SelectCommand="sp_StockType_Select" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
    <dx:ASPxPopupControl ID="popupAddEdit" runat="server" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
        CssPostfix="Aqua" SpriteCssFilePath="~/App_Themes/Aqua/{0}/sprite.css" ClientInstanceName="popupAddEdit"
        HeaderText="Quản lý loại kho" PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" Theme="DevEx"
        EnableClientSideAPI="True" Width="650px" Height="200px">
        <%-- PopupElementID="divPotential" --%>
        <ContentCollection>
           <dx:PopupControlContentControl ID="PopupControlContentControl6" runat="server" SupportsDisabledAttribute="True">
                <div style="width: 100%">
                    <dx:ASPxCallbackPanel ID="cbAddEdit" ClientInstanceName="cbAddEdit" OnCallback="cbAddEdit_Callback" runat="server" Width="100%">
                        <PanelCollection>
                            <dx:PanelContent>
                                <dx:ASPxHiddenField ID="hdfStockType" ClientInstanceName="hdfStockType" runat="server" />
                                <table width="100%">
                                    <tr>
                                        <td style="width: 20%">Loại Kho
                                        </td>
                                        <td style="width: 30%">
                                            <dx:ASPxTextBox ID="txtStockType" ClientInstanceName="txtStockType" runat="server" Theme="DevEx"></dx:ASPxTextBox>
                                        </td>
                                        <td style="width: 20%">Ghi chú
                                        </td>
                                        <td style="width: 30%">
                                           <dx:ASPxTextBox ID="txtDescription" ClientInstanceName="txtDescription" runat="server" Theme="DevEx"></dx:ASPxTextBox>

                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="4">
                                            <dx:ASPxButton ID="ASPxButton1" runat="server" Text="Cập nhật" UseSubmitBehavior="False" AutoPostBack="False">
                                                <ClientSideEvents Click="function(s,e){ gvStockType.PerformCallback('Add'); }" />
                                            </dx:ASPxButton>
                                        </td>
                                    </tr>
                                </table>
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxCallbackPanel>
                </div>
            </dx:PopupControlContentControl>
        </ContentCollection>
    </dx:ASPxPopupControl>
</asp:Content>
